using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using Newtonsoft.Json;

namespace SG.Productivity.DesktopControlPanel.ParallelQuery
{
    [Guid("673A6E82-586C-4BF6-A688-43E633DAE89C")]
    class QueryReply
    {
        [JsonProperty("q")]
        public string Query { get; private set; }

        [JsonProperty("user")]
        public string User { get; private set; }

        [JsonProperty("acceptedProviders")]
        public Uri[] AcceptedProviders { get; private set; }

        public IEnumerable<QueryIdentifier> ProviderSpecificQueries()
        {
            var acceptedProviders = AcceptedProviders;
            var identifiers = new List<QueryIdentifier>(acceptedProviders.Length);
            identifiers.AddRange(acceptedProviders.Select(pProvider => new QueryIdentifier(Query, User, pProvider)));
            return identifiers;
        }
    }
}